[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
itoa() Convert Integer to String
#include <stdlib.h>
char *itoa(value,string,radix);
int value; Number to be converted
char *string; String result
int radix; Base of value
itoa() converts the integer 'value' to a null-terminated string
stored in 'string'. The base used in converting 'value' is specified
by 'radix', which must be in the range 2 - 36, inclusive. The first
character of 'string' is a minus sign (-) if 'value' is negative and
'radix' is 10.
Returns: A pointer to 'string'; no error return.
Notes: itoa() can return up to 17 bytes including the null
character at the end; be certain to allocate enough
space to hold the returned string.
-------------------------------- Example ---------------------------------
The following statements convert an integer to a string and print it
out.
#include <stdlib.h>
#include <stdio.h> /* for printf */
int radix = 10;
char buffer[20];
char *strptr;
main()
{
strptr = itoa(100,buffer,radix);
printf("The amount converted: %s\n",strptr);
}
See Also:
ltoa()
ultoa()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson